package com.fare.taluo.message;

import org.apache.commons.configuration.PropertiesConfiguration;
/**
 * SMS短信消息属性配置类
 * @author xiangsf 2012-12-10
 *
 */
public class SMSMessageProperties {

	public final static String SMS_SERVER_SWITCH = "message.sms.switch";
	public final static String SMS_SERVER = "message.sms.server";
	public final static String SMS_USER = "message.sms.user";
	public final static String SMS_PWD = "message.sms.pwd";
	public final static String SMS_DEFAULT_TO_PHONE = "message.sms.defaultToPhone";
	/**
	 * 短信服务开关
	 */
	private boolean smsServerSwitch = false;
	/**
	 * 短信服务器地址/域名
	 */
	private String smsServer;
	/**
	 * 短信服务登陆用户名
	 */
	private String smsUser;
	/**
	 * 短信登陆密码
	 */
	private String smsPwd;
	/**
	 * 默认发送的目标地址
	 */
	private String defaultToPhone;
	
	public SMSMessageProperties(){}
	
	public SMSMessageProperties(PropertiesConfiguration pc){
		this.setProperties(pc);
	}
	
	public void setProperties(PropertiesConfiguration pc){
		this.smsServerSwitch = pc.getBoolean(SMS_SERVER_SWITCH, false);
		this.smsServer = pc.getString(SMS_SERVER);
		this.smsUser = pc.getString(SMS_USER);
		this.smsPwd = pc.getString(SMS_PWD);
		this.defaultToPhone =  pc.getString(SMS_DEFAULT_TO_PHONE);
	}
	
	public boolean isSmsServerSwitch() {
		return smsServerSwitch;
	}
	public void setSmsServerSwitch(boolean smsServerSwitch) {
		this.smsServerSwitch = smsServerSwitch;
	}
	public String getSmsServer() {
		return smsServer;
	}
	public void setSmsServer(String smsServer) {
		this.smsServer = smsServer;
	}
	public String getSmsUser() {
		return smsUser;
	}
	public void setSmsUser(String smsUser) {
		this.smsUser = smsUser;
	}
	public String getSmsPwd() {
		return smsPwd;
	}
	public void setSmsPwd(String smsPwd) {
		this.smsPwd = smsPwd;
	}
	
	public String getDefaultToPhone() {
		return defaultToPhone;
	}

	public void setDefaultToPhone(String defaultToPhone) {
		this.defaultToPhone = defaultToPhone;
	}

	@Override
	public String toString() {
		StringBuilder builder = new StringBuilder();
		builder.append("SMSMessageProperties [smsServerSwitch=");
		builder.append(smsServerSwitch);
		builder.append(", smsServer=");
		builder.append(smsServer);
		builder.append(", smsUser=");
		builder.append(smsUser);
		builder.append(", smsPwd=");
		builder.append(smsPwd);
		builder.append(", defaultToPhone=");
		builder.append(defaultToPhone);
		builder.append("]");
		return builder.toString();
	}
	
	

}
